<?php

namespace App\Services;

use App\Models\Games;
use App\Models\Orders;
use App\Models\OrdersCallClient;

class PayService extends ServiceBase
{
    // 校验当前是否开放支付
    public function canPay($game_id, $game_channel_id)
    {
        $game = Games::where('game_id', $game_id)->first();
        if ($game->can_pay != 1) {
            return false;
        }

        $game_channel = GameChannelService::getInstance()->get($game_channel_id);
        if ($game_channel['can_pay'] != 1) {
            return false;
        }

        return true;
    }

    // 获取开放哪些支付方式
    public function getOpenPayList($game_id, $game_channel_id = 0)
    {
        $game = Games::where('game_id', $game_id)->first();
        $wxh5_pay = $game->open_wxh5_pay;
        $yibao_pay = $game->open_yibao_pay;
        $yibao_pay = $game->open_alih5_pay;

        $game_channel = GameChannelService::getInstance()->get($game_channel_id);
        if ($game_channel) {
            $wxh5_pay = $game_channel['open_wxh5_pay'];
            $yibao_pay = $game_channel['open_yibao_pay'];
            $alih5_pay = $game_channel['open_alih5_pay'];
        }

        return [
            'wxh5_pay' => $wxh5_pay,
            'yibao_pay' => $yibao_pay,
            'alih5_pay' => $alih5_pay,
        ];
    }
}
